import Vue from 'vue'
import Router from "vue-router"

//组件模块
import login from "@/user/login";
import register from "@/user/register";
import mainPage from "@/components/mainPage";
import detailPage from "@/components/detailPage";
import writeAnswer from "@/components/writeAnswer";
import getComments from "@/components/getComments";
import addQuestion from "@/components/addQuestion";
import personSpace from "@/user/personSpace";
import changeInformation from "@/user/changeInformation";
import alterAnswer from "@/components/changeAnswer";
import searchPage from "@/components/searchPage";
import answerByUser from "@/components/answerByUser";
import personalQuestion from "@/user/personalQuestion";
import messagePage from "@/components/messagePage";
import changeQuestion from "@/user/changeQuestion";
/*







import searchPage from "@/components/searchPage";




import changeAnswer from "@/user/changeAnswer";
import addAnswer from "@/components/addQuestion";

*/

Vue.use(Router)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new Router({
    routes: [
        { path: '/', name: 'login', component: login},
        { path: '/register', name: 'register',component: register},
        { path: '/mainPage', name: 'mainPage', component: mainPage},
        { path: '/detailPage', name: 'detailPage',component: detailPage},
        { path: '/writeAnswer', name: 'writeAnswer',component: writeAnswer, meta:{requireAuth:true}},
        { path: '/getComments', name: 'getComments',component: getComments, meta:{requireAuth:true}},
        { path: '/addQuestion', name: 'addQuestion',component: addQuestion, meta:{requireAuth:true}},
        { path: '/personSpace', name: 'personSpace',component: personSpace, meta:{requireAuth:true}},
        { path: '/changeInformation', name: 'changeInformation',component: changeInformation, meta:{requireAuth:true}},
        { path: '/changeAnswer', name: 'changeAnswer',component: alterAnswer, meta:{requireAuth:true}},
        { path: '/searchPage', name: 'searchPage',component: searchPage},
        { path: '/answerByUser', name: 'answerByUser',component: answerByUser, meta:{requireAuth:true}},
        { path: '/personalQuestion', name: 'personalQuestion',component: personalQuestion, meta:{requireAuth:true}},
        { path: '/messagePage', name: 'messagePage',component: messagePage, meta:{requireAuth:true}},
        { path: '/changeQuestion', name: 'changeQuestion',component: changeQuestion, meta:{requireAuth:true}},
        /*











        { path: '/changeAnswer', name: 'changeAnswer',component: changeAnswer, meta:{requireAuth:true}},
        { path: '/addAnswer', name: 'addAnswer',component: addAnswer, meta:{requireAuth:true}},

        */
    ]
})
